# Maintainer: David Runge <dvzrv@archlinux.org>

_name=rjsmin
pkgname=python-rjsmin
pkgver=1.2.2
pkgrel=1
pkgdesc="Fast javascript minifier for Python"
arch=(loong64 x86_64)
url="https://github.com/ndparker/rjsmin"
license=(Apache-2.0)
depends=(
  glibc
  python
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
)
checkdepends=(python-pytest)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz)
sha512sums=('6df5abe25b56e10a9ed23715a507990965a537a1e2add4984c7ee6732f9aa580d62f18785b0361dc73929e26c0d4ce4c73cad2560132f6a31b8233fc91cb3bdf')
b2sums=('31803f67564911b5785afd03fdc97ce1e8425f8090e2807219a1968d52b463d1272096967137ca3134eedcc331110286f1c0744514ec9bf1b30dcd6763cb7f1c')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {docs/{CHANGES,DESCRIPTION},README.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
